/*
Copyright (C) 2010 
Author		  Oliver Schenk
Contact		  Oliver.Schenk76@gmail.com

This program is free software; you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful, 
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; 
if not, see <http://www.gnu.org/licenses/>.
*/

package SelfBookingSystem;
import java.io.IOException;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DeleteUser extends HttpServlet {

	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
	throws IOException {
		
		System.out.println("TEST");
		System.out.println("TEST " + req.getParameter("AppID"));
		System.out.println("TEST " + req.getParameter("User"));
		
		PersistenceManager pm = PMF.get().getPersistenceManager();

		Query query = pm.newQuery(UserToAppID.class);
	    query.setFilter("AppID == \""+ req.getParameter("AppID") +"\" && User == \"" + req.getParameter("User") + "\"");
		query.deletePersistentAll();		

			resp.sendRedirect("/Admin/index.jsp?AddUser=true&AppID=" + req.getParameter("AppID") + "&GoodCredentials=true");
		
	}
}
